<?php

abstract class Database {
	public abstract function __construct(array $opts);
	
	/**
	 * @param string $query
	 * ...
	 * @return DatabaseResult
	 * @throws DatabaseException
	 */
	public function query() {
		$args = func_get_args();
		if ($args == array()) {
			return;
		}
		$e = explode('?', array_shift($args));
		$query = $e[0];
		for ($i=0; $i<count($args); $i++) {
			$query .= '"'.$this->escape($args[$i]).'"'.$e[$i+1];
		}
		return $this->real_query($query);
	}
	
	public abstract function real_query($query);
	
	/**
	 * @param $result
	 * @return false|array $row
	 */
	public abstract function fetch($result_resource);
	
	public abstract function seek($result_resource, $row_number);
	
	/**
	 * @return false|int
	 */
	public abstract function inserted();
	
	/**
	 * @return false|int
	 */
	public abstract function affected();
	
	/**
	 * @param string $string
	 * @return string
	 */
	public abstract function escape($string);
}
